package com.gis3c.sys.dao.impl;

import com.gis3c.sys.dao.AppDao;
import com.gis3c.sys.entry.po.App;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

/**
 * Created by hukekuan on 18-3-18.
 */
@Repository
public class AppDaoImpl extends SqlSessionDaoSupport implements AppDao {
    @Resource(name="sqlSessionFactory_sys")
    private SqlSessionFactory sqlSessionFactory;

    @PostConstruct
    public void injectSessionFactory(){
        super.setSqlSessionFactory(sqlSessionFactory);
    }


    @Override
    public List<App> findAppList() {
        return getSqlSession().selectList("AppSql.findAppList");
    }

    @Override
    public Integer createApp(App app) {
        return getSqlSession().insert("AppSql.createApp",app);
    }

    @Override
    public void updateApp(App app) {

    }

    @Override
    public Integer deleteApp(String appId) {
        return getSqlSession().delete("AppSql.deleteApp",appId);
    }

    @Override
    public int daleteApps(String... appIds) {
        return 0;
    }

    @Override
    public App findAppById(String appId) {
        return null;
    }

    @Override
    public Integer uncorrelationAppByAppId(String appId) {
        return getSqlSession().delete("AppSql.uncorrelationAppByAppId",appId);
    }
}
